<?PHP
session_start();
session_cache_expire(30);
?>
<!--
	viewWeek.php
	@author Max Palmer
	@version 3/26/08
-->
<html>
<head>
<title>Master Schedule</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<link rel="stylesheet" href="masterschedule.css" type="text/css" />
</head>
<body>
	<div id="container">
		<?PHP include('header.php');?>
		<div id="content">
			<?PHP
			include('masterSchedulePeople.inc');

			if($_SESSION['access_level']<2) {
				die("<p>Only managers can view the master schedule.</p>");
			}
			echo ('<span class="viewweek">');
			include_once('database/dbSchedules.php');
			echo "<br><br>";
			show_schedule("One", "House Master Schedule - Group One");
			echo "<br><br>";
			show_schedule("Two", "House Master Schedule - Group Two");
			echo "<br><br>";
			echo ("<table align=\"center\"><td>");
			show_wknd_schedule(1);
			echo "</td><td></td><td>";
			show_wknd_schedule(2);
			echo "</td><td></td><td>";
			show_wknd_schedule(3);
			echo "</td></table><br><br>";
			echo ("<table align=\"center\"><td>");
			show_wknd_schedule(4);
			echo "</td><td></td><td>";
			show_wknd_schedule(5);
			echo "</td></table>";
			?>
			<?PHP include('footer.inc');?>
		</div>
	</div>
</body>
</html>

<?php
/**
 * gets a week object, and displays it as a calendar
 */
function show_schedule($group, $groupname) {
	$days = array("Mon","Tue","Wed","Thu","Fri");
	$shifts = array("9-12"=>"9-12", "12-15"=>"12-3", "15-18"=>"3-6", "18-21"=>"6-9");

	echo ("<table id=\"calendar\" align=\"center\"><tr><td colspan=\"6\" align=\"center\" class=\"weekname\">".$groupname."</td></tr>
				<tr><td  bgcolor=\"#7991B1\"></td><td class=\"dow\">&nbsp;Monday</td>
				<td class=\"dow\">&nbsp;Tuesday</td>
				<td class=\"dow\">&nbsp;Wednesday</td>
				<td class=\"dow\">&nbsp;Thursday</td>
				<td class=\"dow\">&nbsp;Friday</td></tr>");
	    foreach ($shifts as $shift=>$shiftdisplay) {
		    echo ("<tr><td class=\"hour\">".$shiftdisplay."</td>");
		    foreach ($days as $day ) {
				if ($day=="Fri" && $shift=="18-21")
					echo "<td rowspan=\"3\" bgcolor=\"lightgray\">&nbsp;</td>";
				else
					echo do_shift($group, $day, $shift);
			}
			echo ("<tr><td class=\"hour\"></td></tr>" .
				"<tr><td class=\"hour\"></td></tr>");
			echo ("</tr>" );
	    }
	    echo ("<tr><td class=\"hour\">"."night"."</td>");
	    foreach ($days as $day ) {
				if ($day!="Fri")
					echo "<td rowspan=\"3\" bgcolor=\"lightgray\">&nbsp;</td>";
				else
					echo do_shift($group, $day, "night");
			}
			echo ("<tr><td class=\"hour\"></td></tr>");
			echo ("<tr><td class=\"hour\"></td></tr>");
			echo ("</tr>");

			echo ("</table>");
}

?>